<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style>
			body { margin: 0; }
		</style>
		<script src="../utils/setTitle.js"></script>
	</head>
	<body>
		<script type="importmap">
			{
				"imports": {
					"three": "https://unpkg.com/three/build/three.module.js"
				}
			}
		</script>
		<script type="module">
			import * as THREE from 'three';
			const scene = new THREE.Scene();
			const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
			
			const verticesOfCube = [
				-1,-1,-1,    1,-1,-1,    1, 1,-1,    -1, 1,-1,
				-1,-1, 1,    1,-1, 1,    1, 1, 1,    -1, 1, 1,
			];

			const indicesOfFaces = [
				2,1,0,    0,3,2,
				0,4,7,    7,3,0,
				0,1,5,    5,4,0,
				1,2,6,    6,5,1,
				2,3,7,    7,6,2,
				4,5,6,    6,7,4
			];

			const geometry = new THREE.PolyhedronGeometry( verticesOfCube, indicesOfFaces, 6, 2 );
			const material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} );
			const polyhedron = new THREE.Mesh( geometry, material );
			scene.add( polyhedron );
			camera.position.z = 15;
			const renderer = new THREE.WebGLRenderer();
			renderer.setSize( window.innerWidth, window.innerHeight );
			document.body.appendChild( renderer.domElement );
			function animate() {
				requestAnimationFrame( animate );
				polyhedron.rotation.x += 0.01;
				polyhedron.rotation.y += 0.01;
				renderer.setSize( window.innerWidth, window.innerHeight );
				renderer.render( scene, camera );
			}
			animate();
		</script>
	</body>
</html>